const koa = require('koa');
const router = require('koa-router')();
const app = new koa();
app.use(async (ctx,next)=>{
    console.log(new Date())
    next()
    if(ctx.status == 404){
        ctx.status =404;
        ctx.body="这是一个404页面"
    }
    console.log('路由完成后')
})
router.get('/',async ctx=>{
    console.log("index")
    ctx.body="index"
})
router.get('/detail',async ctx=>{
    console.log('detail')
    ctx.body = "detail"
})

app.use(router.routes()).use(router.allowedMethods())
app.listen(8080)